﻿using System.Collections.Generic;
using Microsoft.SharePoint;

namespace SharePoint.Orm.Metal.Model {
	public class SiteInfo {
		private readonly CodeGeneratorConfiguration _config;
		private readonly HashSet<ListInfo> _lists = new HashSet<ListInfo>();
		private readonly HashSet<ContentTypeInfo> _contentTypes = new HashSet<ContentTypeInfo>();

		public SiteInfo(CodeGeneratorConfiguration config) {
			_config = config;
		}

		public IEnumerable<ContentTypeInfo> ContentTypes {
			get { return _contentTypes; }
		}

		public IEnumerable<ListInfo> Lists {
			get { return _lists; }
		}

		public string DataContextFileName {
			get { return DataContextClassName + _config.DataContextFileNameSuffix + ".cs"; }
		}

		public void AddList(SPList list) {
			_lists.UnionWith(new[] { new ListInfo(_config, list) });
		}

		public void AddContentType(SPContentType contentType) {
			_contentTypes.UnionWith(new[] { new ContentTypeInfo(_config, this, contentType) });
		}

		public string DataContextClassName {
			get { return _config.DataContextClassName; }
		}

		public string DataContextNamespaceName {
			get { return _config.DataContextNamespaceName; }
		}

		public string ContentTypeNamespaceName {
			get { return _config.ContentTypeNamespaceName; }
		}

		public string ListNamespaceName {
			get { return _config.ListNamespaceName; }
		}
	}
}
